from collections import defaultdict

#__all__ = ['privmsg', 'kick']

"""Basic Observer pattern."""

class Observable(defaultdict):
    def __init__ (self, subscriber=None):
        defaultdict.__init__(self, object)

        if subscriber:
            self.subscribe(subscriber)
 
    def emit (self, *args):
        '''Pass parameters to all observers and update states.'''
        for subscriber in self:
            response = subscriber(*args)
            self[subscriber] = response
 
    def subscribe (self, subscriber):
        '''Add a new subscriber to self.'''
        self[subscriber]
 
    def stat (self):
        '''Return a tuple containing the state of each observer.'''
        return tuple(self.values())
class Mode(Observable):
    pass
class Kick(Observable):
    pass

class Privmsg(Observable):
    pass

class Join(Observable):
    pass

class Part(Observable):
    pass

class Quit(Observable):
    pass

class Numeric(Observable):
    pass

class Nick(Observable):
    pass
class Topic(Observable):
    pass
